(function ()
{
    "use strict";

    // The condition of the task is to replace all non breaking whitespaces in a text with &nbsp,
    // but in ASCII there is no code for this symbol so the task is impossible to be solved, I guess.
    // The question is if we read a innerHTML from utf-8 html code, would charCodeAt() return utf-8 char code.

    function whitespacesReplaceWithSymbol(text, symbol)
    {
        var result = "";

        for (var i = 0; i < text.length; i++)
        {
            if (text[i] === " ")
            {
                result += symbol;
            }
            else
            {
                result += text[i];
            }
        }

        return result;
    }
}());